<%--
  Created by IntelliJ IDEA.
  User: 娜娜
  Date: 2024/12/23
  Time: 21:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>员工登录/注册</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-image: url("/img/login.jpg"); /* 背景图片路径 */
            background-size: cover; /* 背景图片覆盖整个页面 */
            background-position: center; /* 背景图片居中 */
            background-repeat: no-repeat; /* 背景图片不重复 */
            background-attachment: fixed; /* 背景图片固定 */
        }



        .container {
            position: relative;
            width: 768px;
            max-width: 100%;
            min-height: 480px;
            background: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
        }

        .form-container {
            position: absolute;
            top: 0;
            height: 100%;
            transition: all 0.6s ease-in-out;
        }

        .login-container {
            left: 0;
            width: 50%;
            z-index: 2;
        }

        .signup-container {
            left: 0;
            width: 50%;
            opacity: 0;
            z-index: 1;
        }

        .container.right-panel-active .login-container {
            transform: translateX(100%);
            opacity: 0;
            z-index: 1;
        }

        .container.right-panel-active .signup-container {
            transform: translateX(100%);
            opacity: 1;
            z-index: 5;
            animation: show 0.6s;
        }

        @keyframes show {
            0%, 49.99% {
                opacity: 0;
                z-index: 1;
            }
            50%, 100% {
                opacity: 1;
                z-index: 5;
            }
        }

        .overlay-container {
            position: absolute;
            top: 0;
            left: 50%;
            width: 50%;
            height: 100%;
            overflow: hidden;
            transition: transform 0.6s ease-in-out;
            z-index: 100;
        }

        .container.right-panel-active .overlay-container {
            transform: translateX(-100%);
        }

        .overlay {
            background: linear-gradient(90deg, #ff9a9e, #fad0c4);
            color: #fff;
            position: relative;
            left: -100%;
            height: 100%;
            width: 200%;
            transform: translateX(0);
            transition: transform 0.6s ease-in-out;
        }

        .container.right-panel-active .overlay {
            transform: translateX(50%);
        }

        .overlay-panel {
            position: absolute;
            top: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 0 40px;
            height: 100%;
            width: 50%;
            text-align: center;
            transform: translateX(0);
            transition: transform 0.6s ease-in-out;
        }

        .overlay-left {
            transform: translateX(-20%);
        }

        .overlay-right {
            right: 0;
            transform: translateX(0);
        }

        .container.right-panel-active .overlay-left {
            transform: translateX(0);
        }

        .container.right-panel-active .overlay-right {
            transform: translateX(20%);
        }

        button {
            border-radius: 20px;
            border: 1px solid #ff4b2b;
            background: #ff4b2b;
            color: #fff;
            font-size: 12px;
            font-weight: bold;
            padding: 12px 45px;
            letter-spacing: 1px;
            text-transform: uppercase;
            transition: transform 80ms ease-in;
            cursor: pointer;
        }

        button:active {
            transform: scale(0.95);
        }

        button.ghost {
            background: transparent;
            border-color: #fff;
        }

        form {
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            padding: 0 50px;
            height: 100%;
            text-align: center;
        }

        input {
            background: #eee;
            border: none;
            padding: 12px 15px;
            margin: 8px 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div class="container" id="container">
    <!-- 登录表单 -->
    <div class="form-container login-container">
        <form action="<%=request.getContextPath()%>/employees" method="post">
            <h1>员工登录</h1>
            <input type="text" id="username" name="username" placeholder="用户名" required />
            <input type="password" id="password" name="password" placeholder="密码" required />
            <button type="submit">登录</button>
        </form>
    </div>

    <!-- 注册表单 -->
    <div class="form-container signup-container">
        <form action="<%=request.getContextPath()%>/register" method="post">
            <h1>员工注册</h1>
            <input type="text" id="username" name="username" placeholder="用户名" required />
            <input type="password" id="password" name="password" placeholder="密码" required />
            <button type="submit">注册</button>
        </form>
        <%
            String registerError = request.getParameter("error");
            if (registerError != null) {
                if (registerError.equals("exists")) {
        %>
        <p style="color: red;">该用户已注册，请使用其他用户名。</p>
        <%
        } else if (registerError.equals("failed")) {
        %>
        <p style="color: red;">注册失败，请重试。</p>
        <%
                }
            }
        %>
    </div>

    <!-- 覆盖层 -->
    <div class="overlay-container">
        <div class="overlay">
            <!-- 左侧覆盖内容 -->
            <div class="overlay-panel overlay-left">
                <h1>欢迎回来！</h1>
                <p>已有账号？请登录以继续</p>
                <button class="ghost" id="login">登录</button>
            </div>
            <!-- 右侧覆盖内容 -->
            <div class="overlay-panel overlay-right">
                <h1>你好，朋友！</h1>
                <p>还没有账号？立即注册</p>
                <button class="ghost" id="signup">注册</button>
            </div>
        </div>
    </div>
</div>

<script>
    const container = document.getElementById('container');
    const signupButton = document.getElementById('signup');
    const loginButton = document.getElementById('login');

    signupButton.addEventListener('click', () => {
        container.classList.add('right-panel-active');
    });

    loginButton.addEventListener('click', () => {
        container.classList.remove('right-panel-active');
    });
</script>
</body>
</html>